aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/mass test client/Commands/Inventory/ExportOutfitCommand.cs
blob: 9a91d0097ba660186da5b3595513f691aabb72e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using libsecondlife;
using libsecondlife.Packets;

namespace libsecondlife.TestClient
{
    public class ExportOutfitCommand : Command
    {
        public ExportOutfitCommand(TestClient testClient)
        {
            Name = "exportoutfit";
            Description = "Exports an avatars outfit to an xml file. Usage: exportoutfit avataruuid outputfile.xml";
        }

        public override string Execute(string[] args, LLUUID fromAgentID)
        {
            if (args.Length != 2)
                return "Usage: exportoutfit avataruuid outputfile.xml";

            LLUUID id;

            try
            {
                id = new LLUUID(args[0]);
            }
            catch (Exception)
            {
                return "Usage: exportoutfit avataruuid outputfile.xml";
            }

            lock (Client.Appearances)
            {
                if (Client.Appearances.ContainsKey(id))
                {
                    try
                    {
						XmlWriterSettings settings = new XmlWriterSettings();
						settings.Indent = true;
						XmlWriter writer = XmlWriter.Create(args[1], settings);
						try
						{
							Client.Appearances[id].ToXml(writer);
						}
						finally
						{
							writer.Close();
						}
                    }
                    catch (Exception e)
                    {
                        return e.ToString();
                    }

                    return "Exported appearance for avatar " + id.ToString() + " to " + args[1];
                }
                else
                {
                    return "Couldn't find an appearance for avatar " + id.ToString();
                }
            }
        }
    }
}